<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/16
 * Time: 8:40
 */

namespace app\common\model;
use think\Model;

class User extends Model
{
    protected $pk = 'id';
    # 自动填写入时间戳
    protected $autoWriteTimestamp = true;

    # 自定义替换时间字段
//    protected $createTime = 'create_time';
//    protected $updateTime = 'update_time';
    # 设置时间的显示格式
    protected $dateFormat = 'Y年m月d日';

    # 获取器
    protected function getStatusAttr($value){
        $status = ['1'=>'启用', '0'=>'禁用'];
        return $status[$value];
    }

    protected function getIsAdminAttr($value){
        $status = ['1'=>'管理员', '0'=>'注册会员'];
        return $status[$value];
    }

    # 修改器
    protected function setPasswordAttr($value){
        return sha1($value);
    }
}